<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>File::chdir - a more sensible way to change directories - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of File-chdir - MetaCPAN" href="https://metacpan.org/dist/File-chdir/releases.rss" />
        <link rel="canonical" href="./File::chdir.html" />
        <meta name="description" content="a more sensible way to change directories" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/File::chdir" />
<meta name="twitter:title"       content="File::chdir" />
<meta name="twitter:description" content="a more sensible way to change directories" />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="./File::chdir.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of File-chdir was released.">
      <span class="relatize">07 Oct 2016 20:59:47 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/File-chdir">File-chdir</a>
  </li>
  <li>
    Module version: 0.1011
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/File-chdir/source/lib/File/chdir.pm">Source</a>
    (<a href="https://metacpan.org/dist/File-chdir/source/lib/File/chdir.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/File-chdir/source/lib/File">Browse</a>
    (<a href="https://metacpan.org/dist/File-chdir/source/lib/File?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/File-chdir/changes">Changes</a>
    </li>
    <li>
      <a rel="noopener nofollow" class="nopopup" href="https://github.com/dagolden/File-chdir">Homepage</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/File-chdir/contribute">How to Contribute</a>
    </li>
    <li>
        <a rel="noopener nofollow" data-keyboard-shortcut="g r" href="https://github.com/dagolden/File-chdir">Repository</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://github.com/dagolden/File-chdir/issues">Issues</a>
      (3)
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=File-chdir+0.1011" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/F/File-chdir.html?oncpan=1&amp;distmat=1&amp;version=0.1011&amp;grade=2" style="color: #090">1614</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/F/File-chdir.html?oncpan=1&amp;distmat=1&amp;version=0.1011&amp;grade=3" style="color: #900">0</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/F/File-chdir.html?oncpan=1&amp;distmat=1&amp;version=0.1011&amp;grade=4">0</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/DAGOLDEN/File-chdir-0.1011">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on File-chdir who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 0
      </div>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpancover.com/latest/File-chdir-0.1011/index.html">85.71% Coverage </a>
    </li>
    <li>
      License: perl_5
    </li>
    <li>
      Perl: v5.6.0
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/File-chdir/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/D/DA/DAGOLDEN/File-chdir-0.1011.tar.gz">
      Download (<span itemprop="fileSize">24.54KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FDAGOLDEN%2FFile-chdir-0.1011%2Flib%2FFile%2Fchdir.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/File-chdir/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/File-chdir/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:File-chdir">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="File-chdir">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/File/chdir.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="DAGOLDEN/File-chdir-0.1011"
>0.1011
  (DAGOLDEN on 2016-10-07)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1010"
>0.1010
  (DAGOLDEN on 2015-02-05)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1009"
>0.1009
  (DAGOLDEN on 2014-09-23)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1008"
>0.1008
  (DAGOLDEN on 2012-12-03)</option>
<optgroup label="BackPAN">'
<option
  
  value="DAGOLDEN/File-chdir-0.1007"
>0.1007
  (DAGOLDEN on 2012-09-18)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1006"
>0.1006
  (DAGOLDEN on 2011-11-02)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1005"
>0.1005
  (DAGOLDEN on 2011-11-02)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1004"
>0.1004
  (DAGOLDEN on 2010-06-09)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1003"
>0.1003
  (DAGOLDEN on 2010-04-28)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1002"
>0.1002
  (DAGOLDEN on 2008-02-12)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1001"
>0.1001
  (DAGOLDEN on 2008-02-09)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.10"
>0.10
  (DAGOLDEN on 2008-02-08)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.09"
>0.09
  (DAGOLDEN on 2007-07-30)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.08"
>0.08
  (DAGOLDEN on 2007-06-22)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.07"
>0.07
  (DAGOLDEN on 2007-06-18)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.06_01"
>0.06_01 DEV
  (DAGOLDEN on 2007-04-09)</option>
<option
  
  value="MSCHWERN/File-chdir-0.06"
>0.06
  (MSCHWERN on 2003-08-15)</option>
<option
  
  value="MSCHWERN/File-chdir-0.05"
>0.05
  (MSCHWERN on 2002-05-04)</option>
<option
  
  value="MSCHWERN/File-chdir-0.03"
>0.03
  (MSCHWERN on 2001-11-26)</option>
<option
  
  value="MSCHWERN/File-chdir-0.02"
>0.02
  (MSCHWERN on 2001-09-03)</option>
<option
  
  value="MSCHWERN/File-chdir-0.01"
>0.01
  (MSCHWERN on 2001-09-01)</option>
</optgroup>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/DAGOLDEN/File-chdir-0.1011/diff/' + encodeURIComponent(this.value) + '/lib/File/chdir.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="DAGOLDEN/File-chdir-0.1011"
>0.1011
  (DAGOLDEN on 2016-10-07)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1010"
>0.1010
  (DAGOLDEN on 2015-02-05)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1009"
>0.1009
  (DAGOLDEN on 2014-09-23)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1008"
>0.1008
  (DAGOLDEN on 2012-12-03)</option>
<optgroup label="BackPAN">'
<option
  
  value="DAGOLDEN/File-chdir-0.1007"
>0.1007
  (DAGOLDEN on 2012-09-18)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1006"
>0.1006
  (DAGOLDEN on 2011-11-02)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1005"
>0.1005
  (DAGOLDEN on 2011-11-02)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1004"
>0.1004
  (DAGOLDEN on 2010-06-09)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1003"
>0.1003
  (DAGOLDEN on 2010-04-28)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1002"
>0.1002
  (DAGOLDEN on 2008-02-12)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1001"
>0.1001
  (DAGOLDEN on 2008-02-09)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.10"
>0.10
  (DAGOLDEN on 2008-02-08)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.09"
>0.09
  (DAGOLDEN on 2007-07-30)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.08"
>0.08
  (DAGOLDEN on 2007-06-22)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.07"
>0.07
  (DAGOLDEN on 2007-06-18)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.06_01"
>0.06_01 DEV
  (DAGOLDEN on 2007-04-09)</option>
<option
  
  value="MSCHWERN/File-chdir-0.06"
>0.06
  (MSCHWERN on 2003-08-15)</option>
<option
  
  value="MSCHWERN/File-chdir-0.05"
>0.05
  (MSCHWERN on 2002-05-04)</option>
<option
  
  value="MSCHWERN/File-chdir-0.03"
>0.03
  (MSCHWERN on 2001-11-26)</option>
<option
  
  value="MSCHWERN/File-chdir-0.02"
>0.02
  (MSCHWERN on 2001-09-03)</option>
<option
  
  value="MSCHWERN/File-chdir-0.01"
>0.01
  (MSCHWERN on 2001-09-01)</option>
</optgroup>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><a href="https://metacpan.org/pod/Carp" title="Carp" class="ellipsis">Carp</a></li>
  <li><a href="https://metacpan.org/pod/Cwd" title="Cwd" class="ellipsis">Cwd</a></li>
  <li><a href="https://metacpan.org/pod/Exporter" title="Exporter" class="ellipsis">Exporter</a></li>
  <li><a href="https://metacpan.org/pod/File::Spec::Functions" title="File::Spec::Functions" class="ellipsis">File::Spec::Functions</a></li>
  <li><a href="https://metacpan.org/pod/strict" title="strict" class="ellipsis">strict</a></li>
  <li><a href="https://metacpan.org/pod/vars" title="vars" class="ellipsis">vars</a></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/File::chdir/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=File%3A%3Achdir">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=File-chdir">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/DAGOLDEN/File-chdir-0.1011/view/lib/File/chdir.pm">This version</a>
    </li>
    <li>
      <a href="./File::chdir.html">Latest version</a>
    </li>
    <li>
<div class="plussers">
<div class="nav-header">++ed by:</div>
<div>
<a class="display-all" href="https://metacpan.org/author/DMOL"><img src="https://www.gravatar.com/avatar/78b28a931707c0fa696996adc7702db9?d=identicon&amp;s=20" title="DMOL" alt="DMOL"></a>
<a class="display-all" href="https://metacpan.org/author/PERLANCAR"><img src="https://www.gravatar.com/avatar/c66c9e215cc2342796cd87ca82d044a8?d=identicon&amp;s=20" title="PERLANCAR" alt="PERLANCAR"></a>
<a class="display-all" href="https://metacpan.org/author/JFRIED"><img src="https://www.gravatar.com/avatar/9b4502d7e2c760dcf5d4416e03e5d0c7?d=identicon&amp;s=20" title="JFRIED" alt="JFRIED"></a>
<a class="display-all" href="https://metacpan.org/author/KEEDI"><img src="https://www.gravatar.com/avatar/95f905a7a4ccc573c711e9d264c0fde8?d=identicon&amp;s=20" title="KEEDI" alt="KEEDI"></a>
<a class="display-all" href="https://metacpan.org/author/ADAMJS"><img src="https://www.gravatar.com/avatar/62c7b6e864d6509cff5839543c676614?d=identicon&amp;s=20" title="ADAMJS" alt="ADAMJS"></a>
</div>
<!-- Display counts of plussers-->
<div>
    <a href="https://metacpan.org/dist/File-chdir/plussers">14 PAUSE users</a>
</div>
<div>
    7 non-PAUSE users
</div>
</div>
    </li>
    <li>
<div id="metacpan_contributors">
  <div>
    <button class="btn-link"
      onclick="$(this).hide(); $('#metacpan_contributors ul').slideDown(); return false;"
    >and 3 contributors</button>
  </div>
  <ul style="display: none">
    <li class="contributor"
      data-contrib-email="schwern@pobox.com"
    >
      <img class="gravatar" width="20" height="20" src="https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?d=identicon&amp;s=20" />
      Michael G. Schwern
    </li>
    <li class="contributor"
      data-cpan-author="JBERGER"
      data-contrib-email="joel.a.berger@gmail.com"
    >
      <a href="https://metacpan.org/author/JBERGER" class="cpan-author">
      <img class="gravatar" width="20" height="20" src="https://www.gravatar.com/avatar/28d0d015d88863cd15e9fd69e0885fc0?d=identicon&amp;s=20" />
      Joel Berger
      </a>
    </li>
    <li class="contributor"
      data-cpan-author="BOOK"
      data-contrib-email="book@cpan.org"
    >
      <a href="https://metacpan.org/author/BOOK" class="cpan-author">
      <img class="gravatar" width="20" height="20" src="https://www.gravatar.com/avatar/caceed5798ea9b855532b257de4686e8?d=identicon&amp;s=20" />
      Philippe Bruhat (BooK)
      </a>
    </li>
  </ul>
</div>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/DAGOLDEN" class="author-name">David Golden</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/File/chdir.pm&#39;" class="">
<option
  selected
  value="DAGOLDEN/File-chdir-0.1011"
>0.1011
  (DAGOLDEN on 2016-10-07)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1010"
>0.1010
  (DAGOLDEN on 2015-02-05)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1009"
>0.1009
  (DAGOLDEN on 2014-09-23)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1008"
>0.1008
  (DAGOLDEN on 2012-12-03)</option>
<optgroup label="BackPAN">'
<option
  
  value="DAGOLDEN/File-chdir-0.1007"
>0.1007
  (DAGOLDEN on 2012-09-18)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1006"
>0.1006
  (DAGOLDEN on 2011-11-02)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1005"
>0.1005
  (DAGOLDEN on 2011-11-02)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1004"
>0.1004
  (DAGOLDEN on 2010-06-09)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1003"
>0.1003
  (DAGOLDEN on 2010-04-28)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1002"
>0.1002
  (DAGOLDEN on 2008-02-12)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.1001"
>0.1001
  (DAGOLDEN on 2008-02-09)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.10"
>0.10
  (DAGOLDEN on 2008-02-08)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.09"
>0.09
  (DAGOLDEN on 2007-07-30)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.08"
>0.08
  (DAGOLDEN on 2007-06-22)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.07"
>0.07
  (DAGOLDEN on 2007-06-18)</option>
<option
  
  value="DAGOLDEN/File-chdir-0.06_01"
>0.06_01 DEV
  (DAGOLDEN on 2007-04-09)</option>
<option
  
  value="MSCHWERN/File-chdir-0.06"
>0.06
  (MSCHWERN on 2003-08-15)</option>
<option
  
  value="MSCHWERN/File-chdir-0.05"
>0.05
  (MSCHWERN on 2002-05-04)</option>
<option
  
  value="MSCHWERN/File-chdir-0.03"
>0.03
  (MSCHWERN on 2001-11-26)</option>
<option
  
  value="MSCHWERN/File-chdir-0.02"
>0.02
  (MSCHWERN on 2001-09-03)</option>
<option
  
  value="MSCHWERN/File-chdir-0.01"
>0.01
  (MSCHWERN on 2001-09-01)</option>
</optgroup>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/File-chdir">File-chdir-0.1011</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage four &#10;
          • 197 direct dependents &#10;          • 2671 total dependents
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="5"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="10"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="15"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="File-chdir-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="File-chdir-0.1011">
    <input type="hidden" name="author" value="DAGOLDEN">
    <input type="hidden" name="distribution" value="File-chdir">
    <button type="submit" class="favorite highlight"><span>21</span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="./File::chdir.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite highlight">
<span>21</span> ++</a>
</div>
   / <span>File::chdir</span>
</div>
          </div>
          <main class="content">


<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="./File::chdir.html#NAME">NAME</a></li>
  <li><a href="./File::chdir.html#VERSION">VERSION</a></li>
  <li><a href="./File::chdir.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="./File::chdir.html#DESCRIPTION">DESCRIPTION</a></li>
  <li><a href="./File::chdir.html#$CWD">$CWD</a></li>
  <li><a href="./File::chdir.html#@CWD">@CWD</a></li>
  <li><a href="./File::chdir.html#EXAMPLES">EXAMPLES</a></li>
  <li><a href="./File::chdir.html#CAVEATS">CAVEATS</a>
    <ul>
      <li><a href="./File::chdir.html#local-@CWD-does-not-work.">local @CWD does not work.</a></li>
      <li><a href="./File::chdir.html#Assigning-to-@CWD-calls-chdir()-for-each-element">Assigning to @CWD calls chdir() for each element</a></li>
      <li><a href="./File::chdir.html#Volumes-not-handled">Volumes not handled</a></li>
    </ul>
  </li>
  <li><a href="./File::chdir.html#NOTES">NOTES</a></li>
  <li><a href="./File::chdir.html#DIAGNOSTICS">DIAGNOSTICS</a></li>
  <li><a href="./File::chdir.html#HISTORY">HISTORY</a></li>
  <li><a href="./File::chdir.html#SEE-ALSO">SEE ALSO</a></li>
  <li><a href="./File::chdir.html#SUPPORT">SUPPORT</a>
    <ul>
      <li><a href="./File::chdir.html#Bugs-/-Feature-Requests">Bugs / Feature Requests</a></li>
      <li><a href="./File::chdir.html#Source-Code">Source Code</a></li>
    </ul>
  </li>
  <li><a href="./File::chdir.html#AUTHORS">AUTHORS</a></li>
  <li><a href="./File::chdir.html#CONTRIBUTORS">CONTRIBUTORS</a></li>
  <li><a href="./File::chdir.html#COPYRIGHT-AND-LICENSE">COPYRIGHT AND LICENSE</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<p>File::chdir - a more sensible way to change directories</p>

<h1 id="VERSION">VERSION</h1>

<p>version 0.1011</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code>  use File::chdir;

  $CWD = &quot;/foo/bar&quot;;     # now in /foo/bar
  {
      local $CWD = &quot;/moo/baz&quot;;  # now in /moo/baz
      ...
  }

  # still in /foo/bar!</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>Perl&#39;s <code>chdir()</code> has the unfortunate problem of being very, very, very global. If any part of your program calls <code>chdir()</code> or if any library you use calls <code>chdir()</code>, it changes the current working directory for the *whole* program.</p>

<p>This sucks.</p>

<p>File::chdir gives you an alternative, <code>$CWD</code> and <code>@CWD</code>. These two variables combine all the power of <code>chdir()</code>, <a href="https://metacpan.org/pod/File::Spec">File::Spec</a> and <a href="https://metacpan.org/pod/Cwd">Cwd</a>.</p>

<h1 id="$CWD"><a id="CWD"></a>$CWD</h1>

<p>Use the <code>$CWD</code> variable instead of <code>chdir()</code> and Cwd.</p>

<pre><code>    use File::chdir;
    $CWD = $dir;  # just like chdir($dir)!
    print $CWD;   # prints the current working directory</code></pre>

<p>It can be localized, and it does the right thing.</p>

<pre><code>    $CWD = &quot;/foo&quot;;      # it&#39;s /foo out here.
    {
        local $CWD = &quot;/bar&quot;;  # /bar in here
    }
    # still /foo out here!</code></pre>

<p><code>$CWD</code> always returns the absolute path in the native form for the operating system.</p>

<p><code>$CWD</code> and normal <code>chdir()</code> work together just fine.</p>

<h1 id="@CWD"><a id="CWD1"></a>@CWD</h1>

<p><code>@CWD</code> represents the current working directory as an array, each directory in the path is an element of the array. This can often make the directory easier to manipulate, and you don&#39;t have to fumble with <code>File::Spec-&gt;splitpath</code> and <code>File::Spec-&gt;catdir</code> to make portable code.</p>

<pre><code>  # Similar to chdir(&quot;/usr/local/src/perl&quot;)
  @CWD = qw(usr local src perl);</code></pre>

<p>pop, push, shift, unshift and splice all work. pop and push are probably the most useful.</p>

<pre><code>  pop @CWD;                 # same as chdir(File::Spec-&gt;updir)
  push @CWD, &#39;some_dir&#39;     # same as chdir(&#39;some_dir&#39;)</code></pre>

<p><code>@CWD</code> and <code>$CWD</code> both work fine together.</p>

<p>*NOTE* Due to a perl bug you can&#39;t localize <code>@CWD</code>. See <a href="./File::chdir.html#CAVEATS">&quot;CAVEATS&quot;</a> for a work around.</p>

<h1 id="EXAMPLES">EXAMPLES</h1>

<p>(We omit the <code>use File::chdir</code> from these examples for terseness)</p>

<p>Here&#39;s <code>$CWD</code> instead of <code>chdir()</code>:</p>

<pre><code>    $CWD = &#39;foo&#39;;           # chdir(&#39;foo&#39;)</code></pre>

<p>and now instead of Cwd.</p>

<pre><code>    print $CWD;             # use Cwd;  print Cwd::abs_path</code></pre>

<p>you can even do zsh style <code>cd foo bar</code></p>

<pre><code>    $CWD = &#39;/usr/local/foo&#39;;
    $CWD =~ s/usr/var/;</code></pre>

<p>if you want to localize that, make sure you get the parens right</p>

<pre><code>    {
        (local $CWD) =~ s/usr/var/;
        ...
    }</code></pre>

<p>It&#39;s most useful for writing polite subroutines which don&#39;t leave the program in some strange directory:</p>

<pre><code>    sub foo {
        local $CWD = &#39;some/other/dir&#39;;
        ...do your work...
    }</code></pre>

<p>which is much simpler than the equivalent:</p>

<pre><code>    sub foo {
        use Cwd;
        my $orig_dir = Cwd::getcwd;
        chdir(&#39;some/other/dir&#39;);

        ...do your work...

        chdir($orig_dir);
    }</code></pre>

<p><code>@CWD</code> comes in handy when you want to start moving up and down the directory hierarchy in a cross-platform manner without having to use File::Spec.</p>

<pre><code>    pop @CWD;                   # chdir(File::Spec-&gt;updir);
    push @CWD, &#39;some&#39;, &#39;dir&#39;    # chdir(File::Spec-&gt;catdir(qw(some dir)));</code></pre>

<p>You can easily change your parent directory:</p>

<pre><code>    # chdir from /some/dir/bar/moo to /some/dir/foo/moo
    $CWD[-2] = &#39;foo&#39;;</code></pre>

<h1 id="CAVEATS">CAVEATS</h1>

<h2 id="local-@CWD-does-not-work."><a id="local"></a><a id="local--CWD-does-not-work"></a><code>local @CWD</code> does not work.</h2>

<p><code>local @CWD</code> will not localize <code>@CWD</code>. This is a bug in Perl, you can&#39;t localize tied arrays. As a work around localizing $CWD will effectively localize @CWD.</p>

<pre><code>    {
        local $CWD;
        pop @CWD;
        ...
    }</code></pre>

<h2 id="Assigning-to-@CWD-calls-chdir()-for-each-element"><a id="Assigning"></a><a id="Assigning-to--CWD-calls-chdir--for-each-element"></a>Assigning to <code>@CWD</code> calls <code>chdir()</code> for each element</h2>

<pre><code>    @CWD = qw/a b c d/;</code></pre>

<p>Internally, Perl clears <code>@CWD</code> and assigns each element in turn. Thus, this code above will do this:</p>

<pre><code>    chdir &#39;a&#39;;
    chdir &#39;a/b&#39;;
    chdir &#39;a/b/c&#39;;
    chdir &#39;a/b/c/d&#39;;</code></pre>

<p>Generally, avoid assigning to <code>@CWD</code> and just use push and pop instead.</p>

<h2 id="Volumes-not-handled"><a id="Volumes"></a>Volumes not handled</h2>

<p>There is currently no way to change the current volume via File::chdir.</p>

<h1 id="NOTES">NOTES</h1>

<p><code>$CWD</code> returns the current directory using native path separators, i.e. <code>\</code> on Win32. This ensures that <code>$CWD</code> will compare correctly with directories created using File::Spec. For example:</p>

<pre><code>    my $working_dir = File::Spec-&gt;catdir( $CWD, &quot;foo&quot; );
    $CWD = $working_dir;
    doing_stuff_might_chdir();
    is( $CWD, $working_dir, &quot;back to original working_dir?&quot; );</code></pre>

<p>Deleting the last item of <code>@CWD</code> will act like a pop. Deleting from the middle will throw an exception.</p>

<pre><code>    delete @CWD[-1]; # OK
    delete @CWD[-2]; # Dies</code></pre>

<p>What should %CWD do? Something with volumes?</p>

<pre><code>    # chdir to C:\Program Files\Sierra\Half Life ?
    $CWD{C} = &#39;\\Program Files\\Sierra\\Half Life&#39;;</code></pre>

<h1 id="DIAGNOSTICS">DIAGNOSTICS</h1>

<p>If an error is encountered when changing <code>$CWD</code> or <code>@CWD</code>, one of the following exceptions will be thrown:</p>

<p>* ~Can&#39;t delete except at the end of @CWD~ * ~Failed to change directory to &#39;$dir&#39;~</p>

<h1 id="HISTORY">HISTORY</h1>

<p>Michael wanted <code>local chdir</code> to work. p5p didn&#39;t. But it wasn&#39;t over! Was it over when the Germans bombed Pearl Harbor? Hell, no!</p>

<p>Abigail and/or Bryan Warnock suggested the <code>$CWD</code> thing (Michael forgets which). They were right.</p>

<p>The <code>chdir()</code> override was eliminated in 0.04.</p>

<p>David became co-maintainer with 0.06_01 to fix some chronic Win32 path bugs.</p>

<p>As of 0.08, if changing <code>$CWD</code> or <code>@CWD</code> fails to change the directory, an error will be thrown.</p>

<h1 id="SEE-ALSO"><a id="SEE"></a>SEE ALSO</h1>

<p><a href="https://metacpan.org/pod/File::pushd">File::pushd</a>, <a href="https://metacpan.org/pod/File::Spec">File::Spec</a>, <a href="https://metacpan.org/pod/Cwd">Cwd</a>, <a href="functions/CORE.html#chdir">&quot;chdir&quot; in perlfunc</a>, &quot;Animal House&quot; <a href="http://www.imdb.com/title/tt0077975/quotes">http://www.imdb.com/title/tt0077975/quotes</a></p>

<h1 id="SUPPORT">SUPPORT</h1>

<h2 id="Bugs-/-Feature-Requests"><a id="Bugs"></a><a id="Bugs---Feature-Requests"></a>Bugs / Feature Requests</h2>

<p>Please report any bugs or feature requests through the issue tracker at <a href="https://github.com/dagolden/File-chdir/issues">https://github.com/dagolden/File-chdir/issues</a>. You will be notified automatically of any progress on your issue.</p>

<h2 id="Source-Code"><a id="Source"></a>Source Code</h2>

<p>This is open source software. The code repository is available for public review and contribution under the terms of the license.</p>

<p><a href="https://github.com/dagolden/File-chdir">https://github.com/dagolden/File-chdir</a></p>

<pre><code>  git clone https://github.com/dagolden/File-chdir.git</code></pre>

<h1 id="AUTHORS">AUTHORS</h1>

<ul>

<li><p>David Golden &lt;dagolden@cpan.org&gt;</p>

</li>
<li><p>Michael G. Schwern &lt;schwern@pobox.com&gt;</p>

</li>
</ul>

<h1 id="CONTRIBUTORS">CONTRIBUTORS</h1>

<ul>

<li><p>David Golden &lt;xdg@xdg.me&gt;</p>

</li>
<li><p>Joel Berger &lt;joel.a.berger@gmail.com&gt;</p>

</li>
<li><p>Philippe Bruhat (BooK) &lt;book@cpan.org&gt;</p>

</li>
</ul>

<h1 id="COPYRIGHT-AND-LICENSE"><a id="COPYRIGHT"></a>COPYRIGHT AND LICENSE</h1>

<p>This software is copyright (c) 2016 by Michael G. Schwern and David Golden.</p>

<p>This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.</p></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install File::chdir, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm File::chdir</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install File::chdir</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="./File::chdir.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
